package yxy.cherry.battle.module.affix.skill;

import yxy.cherry.battle.Battle;
import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.module.affix.AffixContext;
import yxy.cherry.battle.module.affix.AffixContext.AffixTarget;
import yxy.cherry.battle.module.affix.AffixFactory.SkillTypeEnum;
import yxy.cherry.battle.module.affix.Skill;
import yxy.cherry.battle.module.affix.SkillType;
import yxy.cherry.data.bean.skill;

import java.util.ArrayList;

/** 增伤靠减血 */
@SkillType(Type = SkillTypeEnum.增伤靠减血)
public class Affix_17_增伤靠减血 extends Skill {
	// 战斗中自身生命每降低X%，伤害增加X%；

	private int get减血比例() {
		return getParam(0);
	}
	private int get增伤比例() {
		return getParam(1);
	}

	public Affix_17_增伤靠减血(Fighter actor, skill skilldata, int probability, int[] params) {
		super(actor, skilldata, probability, params);
	}

	@Override
	public boolean exec(Fighter actor, Fighter target) {
		long 减血万分值 = VALUE_比率分母 - actor.get血量万分值();
		int 增伤倍数 = (int) 减血万分值 / get减血比例();

		AffixContext.AffixAction affixAction = getAffixAction();
		AffixTarget affixTarget = getAffixAction().getTarget(target);
		if(target.equals(affixAction.get针对目标())) {
			ArrayList<Long> 结算伤害流 = genFinalDamage(affixTarget.get伤害流(), affixTarget.getBaseDamageList(), 增伤倍数 * get增伤比例());
			Battle.battleLogger(6,"增伤靠减血：施法者：" + actor.getName() + "对象：" + affixTarget.get目标().getName() + "减血万分值："+减血万分值+"减血比例："+get减血比例()+"增伤比例："+get增伤比例()+"原始伤害：" + affixTarget.get伤害流().toString() +"基础伤害："+affixTarget.getBaseDamageList().toString()+ "增伤：" + 结算伤害流.toString());
			affixTarget.set伤害流(结算伤害流);
		}

		return true;
	}

}